﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snowdreamist.ComponentModel.Plugin;

namespace Snowdreamist.ComponentModel.MEF
{
    public class MEFImportedPlugin<T> : ImportedPlugin<T>
    {
        public MEFImportedPlugin(Lazy<T> lazyPart)
        {
            if (lazyPart == null)
                throw new ArgumentNullException("lazyPart");
            this._lazyPart = lazyPart;
        }

        public override T Plugin
        {
            get
            {
                return this._lazyPart.Value;
            }
        }

        private Lazy<T> _lazyPart;
    }

    public class MEFImportedPlugin<T, TMetadata> : ImportedPlugin<T, TMetadata>
    {
        public MEFImportedPlugin(Lazy<T, TMetadata> lazyPart)
        {
            if (lazyPart == null)
                throw new ArgumentNullException("lazyPart");
            this._lazyPart = lazyPart;
        }

        public override T Plugin
        {
            get
            {
                return this._lazyPart.Value;
            }
        }

        public override TMetadata Metadata
        {
            get
            {
                return this._lazyPart.Metadata;
            }
        }

        private Lazy<T, TMetadata> _lazyPart;
    }
}